home *** CD-ROM | disk | FTP | other *** search
/ Languguage OS 2 / Languguage OS II Version 10-94 (Knowledge Media)(1994).ISO / gnu / perl5000.zip / perl5000 / t / TEST < prev   
Encoding:
Text File  |  1994-08-26  |  2.1 KB  |  107 lines

  1. #!./perl
  2.  
  3. # $RCSfile: TEST,v $$Revision: 4.1 $$Date: 92/08/07 18:27:00 $
  4.  
  5. # This is written in a peculiar style, since we're trying to avoid
  6. # most of the constructs we'll be testing for.
  7.  
  8. $| = 1;
  9.  
  10. if ($ARGV[0] eq '-v') {
  11.     $verbose = 1;
  12.     shift;
  13. }
  14.  
  15. chdir 't' if -f 't/TEST';
  16.  
  17. if ($ARGV[0] eq '') {
  18.     @ARGV = split(/[ \n]/,
  19.       `echo base/*.t comp/*.t cmd/*.t io/*.t; echo op/*.t lib/*.t`);
  20. }
  21.  
  22. open(CONFIG,"../config.sh");
  23. while (<CONFIG>) {
  24.     if (/sharpbang='(.*)'/) {
  25.     $sharpbang = ($1 eq '#!');
  26.     last;
  27.     }
  28. }
  29. $bad = 0;
  30. $good = 0;
  31. $total = @ARGV;
  32. while ($test = shift) {
  33.     if ($test =~ /^$/) {
  34.     next;
  35.     }
  36.     $te = $test;
  37.     chop($te);
  38.     print "$te" . '.' x (15 - length($te));
  39.     if ($sharpbang) {
  40.     open(results,"./$test |") || (print "can't run.\n");
  41.     } else {
  42.     open(script,"$test") || die "Can't run $test.\n";
  43.     $_ = <script>;
  44.     close(script);
  45.     if (/#!..perl(.*)/) {
  46.         $switch = $1;
  47.     } else {
  48.         $switch = '';
  49.     }
  50.     open(results,"./perl$switch $test |") || (print "can't run.\n");
  51.     }
  52.     $ok = 0;
  53.     $next = 0;
  54.     while (<results>) {
  55.     if ($verbose) {
  56.         print $_;
  57.     }
  58.     unless (/^#/) {
  59.         if (/^1\.\.([0-9]+)/) {
  60.         $max = $1;
  61.         $totmax += $max;
  62.         $files += 1;
  63.         $next = 1;
  64.         $ok = 1;
  65.         } else {
  66.         $next = $1, $ok = 0, last if /^not ok ([0-9]*)/;
  67.         if (/^ok (.*)/ && $1 == $next) {
  68.             $next = $next + 1;
  69.         } else {
  70.             $ok = 0;
  71.         }
  72.         }
  73.     }
  74.     }
  75.     $next = $next - 1;
  76.     if ($ok && $next == $max) {
  77.     print "ok\n";
  78.     $good = $good + 1;
  79.     } else {
  80.     $next += 1;
  81.     print "FAILED on test $next\n";
  82.     $bad = $bad + 1;
  83.     $_ = $test;
  84.     if (/^base/) {
  85.         die "Failed a basic test--cannot continue.\n";
  86.     }
  87.     }
  88. }
  89.  
  90. if ($bad == 0) {
  91.     if ($ok) {
  92.     print "All tests successful.\n";
  93.     } else {
  94.     die "FAILED--no tests were run for some reason.\n";
  95.     }
  96. } else {
  97.     $pct = sprintf("%.2f", $good / $total * 100);
  98.     if ($bad == 1) {
  99.     warn "Failed 1 test, $pct% okay.\n";
  100.     } else {
  101.     die "Failed $bad/$total tests, $pct% okay.\n";
  102.     }
  103. }
  104. ($user,$sys,$cuser,$csys) = times;
  105. print sprintf("u=%g  s=%g  cu=%g  cs=%g  files=%d  tests=%d\n",
  106.     $user,$sys,$cuser,$csys,$files,$totmax);
  107.